<?=$system_message;?>

<div class="section-container auto" data-section data-options="deep_linking: true">
  <section class="active">
    <p class="title" data-section-title><a href="#create-login">Edit Parent Login</a></p>
    <div class="content" data-slug="create-login" data-section-content>
    	<span class="clearfix"></span>
		<?=form_open('','onsubmit="return validate(event)"')?>
			<div class="panel">
			<div class="row">
				<div class="large-6 columns">
					<label>
						<input type="checkbox" name="inc_username" id="inc_username" checked="">
						&nbsp; User Email
					</label>
					<input class="email" type="email" name="parent_username" placeholder="parentsemail@email.com" value="<?=set_value('parent_username', $parent->username);?>"  title="Parent Email">
				</div>
			</div>
			<div class="row">
				<div class="large-6 columns">
					<label>
						<input type="checkbox" name="inc_password" id="inc_password">
						&nbsp; Password
					</label>
					<input disabled class="password" pattern=".{6,30}" title="6 to 30 characters only" type="password" required name="parent_password" id="parent_password"  placeholder="parent's password"  title="Password for parent">
					<label>Confirm Password</label><br/>
					<input disabled class="password" pattern=".{6,30}" title="6 to 30 characters only" type="password" required name="parent_cpassword" id="parent_cpassword" placeholder="confirm parent's password" title="Confirm Password for parent">
				</div>
			</div>
			</div>
			<hr class="clearfix">
			<input type="hidden" name="form_token" value="<?=$form_token?>">
			<input type="submit" value="Update Parent Login" name="update_parent_login" class="btn btn-primary">
			<a href="<?=site_url('user/parentlogin#parent-login')?>" class="btn btn-default">Cancel</a>
		</form>
    </div>
  </section>
</div>
<script type="text/javascript" src="<?=script_url('custom/createlogin');?>"></script>
<script type="text/javascript" src="<?=script_url('custom/ajaxclick');?>"></script>
<script type="text/javascript">
	$('#inc_username').on('change', function(){
		if($(this).is(':checked')){
			$('.email').removeAttr('disabled');
		}else{
			$('.email').attr('disabled', true);
		}
	});
	$('#inc_password').on('change', function(){
		if($(this).is(':checked')){
			$('.password').removeAttr('disabled');
		}else{
			$('.password').attr('disabled', true);
		}
	})
	$('#parent_cpassword').on('blur', function(){
		if($('#parent_password').val() != $('#parent_cpassword').val()){
			$.growl.warning({ message: "Password don't match!" });
			return false;
		}
	})

	function validate (e) {
		// e.preventDefault();
		return true;
		var ans = confirm('Are you sure?');
		if(ans){

			if($('#inc_password').is(':checked')){

				if($('#parent_password').val() != $('#parent_cpassword').val()){

					$.growl.error({ message: "Password don't match!" });
					return false;
				}
				else{
					return true;
				}
			}
			else{
				return true;
			}
		}
		else{
			return false;
		}
	}
</script>